#ifndef H_COMPONENT_H
#define H_COMPONENT_H
#include <string>
#include <iostream>
namespace CompositeMode
{
    class Component
    {
    public:
        //添加组件
        virtual void add(Component* c) = 0;
        //移除组件
        virtual void remove(Component* c) = 0;
        //获取子组件
        virtual Component* getChild(int i) = 0;
        //组件操作
        virtual void operation() = 0;
    };
}
#endif

// CompositeMode::Composite* c0 = new CompositeMode::Composite;
// CompositeMode::Composite* c1 = new CompositeMode::Composite;
// CompositeMode::Leaf* leaf1 = new CompositeMode::Leaf("1");
// CompositeMode::Leaf* leaf2 = new CompositeMode::Leaf("2");
// CompositeMode::Leaf* leaf3 = new CompositeMode::Leaf("3");
// c0->add(leaf1);
// c0->add(c1);
// c1->add(leaf2);
// c1->add(leaf3);
// c0->operation();